#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
long long a[3][1000000],c[1000000];
int b[1000000];
int main()
{
	freopen("duel.in","r",stdin);
	freopen("duel.out","w",stdout);
	long long n,i,k,m=1,ans;
	cin>>n;
	ans=n;
	for(i=1;i<=n;i++)
	{
		cin>>k;
		if(b[k]==0)
		{
		b[k]=m;
		a[1][m]++;
		a[2][m]++;
		m++;
	    }
	    else
	    a[1][b[k]]++;//gongji
	    a[2][b[k]]++;//renshu
	}
	for(i=1;i<=m;i++)
	{
		if(a[1][i+1]>a[2][i])
		{
			ans=ans-a[2][i];
			a[1][i+1]=a[1][i+1]-a[2][i];
		}
		else 
		{
		ans=ans-a[1][i+1];
		a[1][i+1]=0;
		a[2][i+1]=a[2][i]-a[1][i+1]+a[2][i+1];
		}		
	}
	cout<<ans;
	return 0;
} 
